/*-----------------------------------------------------------------------------
	The contents of this file are subject to the Mozilla Public License
	Version 1.1 (the "License"); you may not use this file except in
	compliance with the License. You may obtain a copy of the License at
	http://www.mozilla.org/MPL/
	
	Software distributed under the License is distributed on an "AS IS"
	basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
	License for the specific language governing rights and limitations
	under the License.
	
	The Original Code is Fever Framework code.
	
	The Initial Developer of the Original Code is Romain Ecarnot.
	Portions created by Initial Developer are Copyright (C) 2006
	the Initial Developer. All Rights Reserved.
	
	Contributor(s):
	
	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the License for the specific language governing permissions and
	limitations under the License.
-----------------------------------------------------------------------------*/

import org.aswing.Icon;

import fever.app.local.LocalisationEvent;
import fever.core.Resources;

import fvaswing.components.filechooser.icons.FvFileIcon;
import fvaswing.components.filechooser.icons.FvFolderIcon;
import fvaswing.components.filechooser.icons.FvHomeIcon;
import fvaswing.components.filechooser.icons.FvParentIcon;
import fvaswing.components.filechooser.icons.FvUploadIcon;

/**
 * Graphical and localisation properties for {@link fvaswing.components.FvFileChooser} 
 * component.
 * 
 * <p>You can redefine icons used for 'home' and 'parent' button using {@link #homeIcon} 
 * and {@link parentIcon} properties.
 * 
 * <p>You can redefine default used icons for 'folder' and 'file' itemu sing {@link #fileIcon} 
 * and {@link folderIcon} properties.
 * 
 * <p>Modifications are applied to all instanciated FvFileChooser as localisation 
 * work with <strong>Singleton</strong> design.
 * 
 * <p>Default localisation use 'english' language.
 * 
 * <p>FvFileChooser in french for example : 
 * {@code
 *   var resource : FvFileChooserResources = FvFileChooserResources.getInstance();
 *   resource.openLabel = "Ouvrir";
 *   resource.cancelLabel = "Annuler";
 *   resource.lookIn = "Chercher dans :";
 *   resource.fileName = "Nom de fichier :";
 *   resource.fileType = "Type de fichier :";
 *   
 *   var chooser : FvFileChooser = new FvFileChooser();
 *   chooser.showOpenDialog();
 * }
 *
 * @author Romain Ecarnot
 */
class fvaswing.components.filechooser.FvFileChooserResources extends Resources
{
	//-------------------------------------------------------------------------
	// Constants definition
	//-------------------------------------------------------------------------
	
	/** ID for 'Open' dialog. */
	public static var OPEN : Number = 1;
	
	/** ID for 'Save' dialog. */
	public static var SAVE : Number = 2;
	
	/** ID for 'Browse' dialog. */
	public static var BROWSE : Number = 3;
	
	/** ID for 'Custom' dialog. */	public static var CUSTOM : Number = 10;
	
	
	//-------------------------------------------------------------------------
	// Private properties
	//-------------------------------------------------------------------------
	
	private static var _instance : FvFileChooserResources;
	
	
	//-------------------------------------------------------------------------
	// Public Properties
	//-------------------------------------------------------------------------
		
	public var openLabel : String;
	public var saveLabel : String;
	public var folderLabel : String;
	public var cancelLabel : String;
	public var lookInLabel : String;
	public var fileTypeLabel : String;
	public var fileNameLabel : String;
	public var noPreviewLabel : String;
	public var loadPreviewLabel : String;
	public var uploadLabel : String;
	public var createFolderLabel : String;
	
	public var homeIcon : Icon;
	public var parentIcon : Icon;
	public var folderIcon : Icon;
	public var fileIcon : Icon;
	public var uploadIcon : Icon;
	public var refreshIcon : Icon;	public var createIcon : Icon;
	
	
	//-------------------------------------------------------------------------
	// Public API
	//-------------------------------------------------------------------------
	
	/**
	 * Returns {@link FvFileChooserResources} instance.
	 * 
	 * <p>Singleton design
	 */
	public static function getInstance() : FvFileChooserResources
	{
		if( !_instance ) _instance = new FvFileChooserResources();
		return _instance;
	}
	
	public function onLocalisationUpdate( event : LocalisationEvent ) : Void
	{
		openLabel = getTranslation( 'openLabel' );
		saveLabel = getTranslation( 'saveLabel' );
		folderLabel = getTranslation( 'folderLabel' );
		cancelLabel = getTranslation( 'cancelLabel' );
		lookInLabel = getTranslation( 'lookInLabel' );
		fileNameLabel = getTranslation( 'fileNameLabel' );
		fileTypeLabel = getTranslation( 'fileTypeLabel' );
		noPreviewLabel = getTranslation( 'noPreviewLabel' );
		loadPreviewLabel = getTranslation( 'loadPreviewLabel' );
		uploadLabel = getTranslation( 'uploadLabel' );		createFolderLabel = getTranslation( 'createFolderLabel' );
	}
	
	
	//-------------------------------------------------------------------------
	// Private implementation
	//-------------------------------------------------------------------------
	
	/**
	 * Constructor.
	 */
	private function FvFileChooserResources()
	{
		super( 'fvaswing:filechooser' );
		
		_initIcons();
	}
	
	private function _initDefault() : Void
	{
		openLabel = 'Open';
		saveLabel = 'Save';
		folderLabel = 'Choose';
		cancelLabel = 'Cancel';
		lookInLabel = 'Look in :';
		fileNameLabel = 'File name :';
		fileTypeLabel = 'File type :';
		noPreviewLabel = 'No preview available';
		loadPreviewLabel = 'view';
		uploadLabel = 'Upload';		createFolderLabel = 'New folder';
	}
	
	private function _initIcons() : Void
	{
		parentIcon = new FvParentIcon();
		homeIcon = new FvHomeIcon();
		
		folderIcon = new FvFolderIcon();
		fileIcon = new FvFileIcon();
		uploadIcon = new FvUploadIcon();
	}
}